package top.jle.locker.integration;

import org.noear.solon.cloud.CloudManager;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;
import top.jle.locker.annotation.OperationLock;
import top.jle.locker.service.CloudLockServiceRedissonImpl;

public class XPluginImpl implements Plugin {
    @Override
    public void start(AppContext context) {
        boolean enable = context.cfg().getBool("locker.enable", true);
        if (enable) {
            context.beanScan("top.jle.locker");
            context.beanInterceptorAdd(OperationLock.class, OperationLockInterceptor.instance, 120);
            CloudManager.register(new CloudLockServiceRedissonImpl(context.getBean(Locker.class)));
        }
    }
}
